package com.ruoyi.statisticalCenter.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.statisticalCenter.domain.vo.ScFlowReportDispositionVo;
import com.ruoyi.statisticalCenter.service.ScFlowReportDispositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 *  流向报表参数配置配置
 *  @author cmz
 *  @date 2024-04-08
 */

@RestController
@RequestMapping("/sc/flowReport")
@Api(tags = "统计中心-流向报表")
public class ScFlowReportDispositionController  extends BaseController
{
    @Resource
    private ScFlowReportDispositionService scFlowReportDispositionService;

    @ApiOperation("查询流向报表数据")
    @GetMapping("/collect")
    public R collect(
            @ApiParam(value = "开始时间(yyyy-mm-dd)") String start_date,
            @ApiParam(value = "结束时间(yyyy-mm-dd)") String end_date,
            @ApiParam(value = "统计维度(网点/承包区)") String statistical_dimension,
            @ApiParam(value = "承包区名称") String contract_area
    ) {
        Map<String,Object> parametersMap = new HashMap<>();
        parametersMap.put("start_date", start_date);
        parametersMap.put("end_date", end_date);
        parametersMap.put("statistical_dimension", statistical_dimension);
        parametersMap.put("contract_area", contract_area);
        return scFlowReportDispositionService.collect(parametersMap);
    }

    @ApiOperation("导出流向报表数据")
    @GetMapping("/export")
    public R export(
            @ApiParam(value = "开始时间(yyyy-mm-dd)") String start_date,
            @ApiParam(value = "结束时间(yyyy-mm-dd)") String end_date,
            @ApiParam(value = "统计维度(网点/承包区)") String statistical_dimension,
            @ApiParam(value = "承包区名称") String contract_area,
            @ApiParam(value = "导出文件位置名称") String path,
            @ApiParam(value = "Excel页名称") String sheetName
    ) {

        return scFlowReportDispositionService.export(start_date,end_date,statistical_dimension,contract_area,path,sheetName);
    }

    @PostMapping("/updateDisposition")
    @ApiOperation("修改流向报表配置参数")
    public R updateDisposition(@RequestBody ScFlowReportDispositionVo scFlowReportDispositionVo)
    {
        return scFlowReportDispositionService.updateDisposition(scFlowReportDispositionVo);
    }

    @GetMapping("/selectDisposition")
    @ApiOperation("查询流向报表配置参数")
    public R selectDisposition()
    {
        return scFlowReportDispositionService.selectDisposition();
    }

}
